//
//  LBDownloaderBlockOperation.h
//  LBDownloader
//
//  Created by WuShiHai on 19/6/14.
//  Copyright (c) 2019 Lebbay All rights reserved.
//
#import <Foundation/Foundation.h>
#import "LBDownloaderWork.h"

typedef void(^LBDownloaderCompleteBlock)(BOOL isSuccess, LBDownloaderModel *downloader);
typedef void(^LBDownloadProgressBlock)(NSProgress *downloadProgress);

@class LBDownloaderBlockOperation;

@protocol LBDownloaderBlockOperationDelegate <NSObject>

/**
 操作完成时的回调
 
 @param operation 操作
 */
- (void)didOperationCompleteTask:(LBDownloaderBlockOperation *)operation;

@end

@interface LBDownloaderBlockOperation : NSBlockOperation

/**
 委托
 */
@property (nonatomic, weak) id<LBDownloaderBlockOperationDelegate> delegate;

/**
 每个任务对应work
 */
@property (nonatomic, strong) LBDownloaderWork *work;

/**
 任务完成后的回调
 */
@property (nonatomic, copy) LBDownloaderCompleteBlock complete;

/**
 任务下载时的回调
 */
@property (nonatomic, copy) LBDownloadProgressBlock downloadProgress;

/**
 是否只读缓存，而不去下载
 */
@property (nonatomic, assign) BOOL cacheOnly;

/**
 操作是否成功
 */
@property (nonatomic, assign, readonly) BOOL isSuccess;

@end
